<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //寻找满足n的平方和大于456789的最小整数
        //穷举法 从1开始试验
        // var n = 1;
        // while (n * n < 456789) {
        //     n++;
        // }

        // console.log(n); //676


        var n = 1;
        var sum = 0;
        while (sum < 500) {
            sum += n;
            n++;
        }
        //注意这里有个“出一错误”
        console.log(n - 1); //32
    </script>
</body>

</html>